Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is actually a minor breaking change: the API has changed from
eqx.nn.StateIndex(callable_returning_value)
to justeqx.nn.StateIndex(value)
. In practice creating custom stateful layers was an advanced API surface that wasn't really documented before, so I'm tempted to release this as av0.10.*
release, rather than bumping tov0.11.0
.This also updates the recommended way of creating state from
eqx.nn.State(model)
toeqx.nn.make_with_state(model)
. This is needed to ensure memory usage behaves correctly. Nonetheless the previouseqx.nn.State(model)
approach will do the correct thing (other than consuming some extra memory), for backward compatibility.This change also introduces substantially updated documentation on stateful layers, which should help usage here a lot.
For information on how things now work, first take a look at this example for the "normal" API, and then this further documentation for more details on creating custom layers, and using stateful layers with vmap.